home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / notes / perf < prev    next >
Encoding:
Text File  |  1992-08-03  |  7.0 KB  |  194 lines

  1. Notes, ideas about performance
  2.  
  3.  
  4.     - Context switches -
  5.  
  6. W/i Sprite server, do you lose much when signalling a process because
  7. (in Sync_WakeWaitingProcess) you do a broadcast on the condition
  8. variable, rather than waking only the one process?
  9.  
  10. How much do you lose by doing context switches in the RPC processing
  11. path?
  12.  
  13.  
  14.     - Segment management -
  15.  
  16. How often does segment lookup have to bail out and start over because
  17. the desired segment was in the middle of being destroyed?
  18.  
  19. How much time would you save by having Sprite cache segments, rather
  20. than forcing them to be "immediately" destroyed?  (If you implement
  21. this, look at Fs_GetSegPtr and how native Sprite stashes away the
  22. segment handle.)
  23.  
  24. How much time do you win by renaming the port to be the segment
  25. handle?
  26.  
  27. How much is exec speeded up by using an initialization file for the
  28. heap?
  29.  
  30. How much time is lost by always opening and closing the swap file?
  31. For a short lived process, you may never need to go to the swap file,
  32. so why bother opening it?  [Cost is significant: doubles the time of
  33. the fork benchmark.]
  34.  
  35. Try to understand the read-ahead stuff done by native Sprite
  36. (vmServer.c).  How much does it buy you?
  37.  
  38. How much time do you spend releasing the reference on the control port
  39. in the data_request, data_write, etc. routines?
  40.  
  41. How much time do you spend cleaning "anonymous" (heap & stack)
  42. segments at process exit?
  43.  
  44. Understand the Fs_FileBeingMapped calls: how they're used, how they
  45. affect performance.  See the comments in VmSegmentCleanup.
  46.  
  47. How much time is spent waiting to process a request because the server
  48. is already processing a request for the given memory object?  (For
  49. example, you can't currently page-in in parallel multiple pages for a
  50. text segment.)
  51.  
  52. How much time do you lose querying for the size of the swap file in
  53. VmCopySwapFile?  Should you keep that information in the Vm_Segment
  54. (and update it from memory_object_write)?
  55.  
  56. How much time is spent waiting for the VM monitor lock?  How often is
  57. the lock held while doing an RPC?  (For example, as of 9-Jan-92, the
  58. code path for destroying a segment would hold the VM monitor lock
  59. while trying to notify the file server that the file was no longer
  60. mapped.  Also, Vm_GetSwapSegment holds the monitor lock while calling
  61. VmOpenSwapFile.)
  62.  
  63. How much time in fork() is spent copying initialized heap pages?
  64.  
  65.  
  66.     - processes -
  67.  
  68. Have you allocated enough Proc_ServerProcs?  Too many?  Should you
  69. split the FS cache and VM server processes into separate pools?  You
  70. might want to look at Mendel's changes to allow an expandable pool of
  71. Proc_ServerProcs (procServer.h, procServer.c, proc.h).
  72.  
  73. How much do you lose by only having one thread to get requests and do
  74. pcb reaping?  Would it be better to have multiple threads, each of
  75. which goes through "obtain lock -> process dead list -> get msg ->
  76. release lock"?  (What is the cost of two mach_msg's and two context
  77. switches compared to the overall request processing time?)  Also,
  78. there are a bunch of messages from late October and early November
  79. 1991 about the cthread_mach_mumble routines used in the UX server that
  80. you should review.
  81. Note: a possible alternative to locking (to avoid the process re-use
  82. race) is to use no-senders notification.  You may need to take
  83. advantage of sequence numbers; see Richard Draves's message of August
  84. 9, 1991.
  85.  
  86.  
  87.     - network -
  88.  
  89. How much time is required for a null RPC?  How does that compare with
  90. native Sprite?  Where is the time going?
  91.  
  92. Disable the RPC delay code?
  93. [The way things are currently configured, this shouldn't make a
  94. difference.  Sun 3's, Sun 4's, and DECstations are all set with input
  95. and output times of 500 usec, and the RPC output code uses the
  96. difference between the receiver input rate and the sender output rate
  97. (i.e., 0) as the amount to delay.]
  98.  
  99. What is the efficiency of the FS and VM caches?  Would having cache
  100. size negotiation make the caches more efficient?
  101.  
  102. Instrument the driver to find out how long the packet queue is.  Maybe
  103. you should have multiple ReadPortSet threads.
  104.  
  105. Don't bother with the UtilsMach_Delay calls?
  106.  
  107. Should you re-enable the Proc_SetServerPriority call in
  108. Rpc_CreateServer?
  109.  
  110. When comparing native and server Sprite, get an RPC count for the
  111. benchmark (i.e., find out where sprited is doing more RPC's than
  112. native Sprite and figure out if there's some good way to fix it).
  113.  
  114.  
  115.     - server memory usage -
  116.  
  117. How much paging does the server do?  Are there data structures that
  118. can be shrunk (e.g., VmFileMap)?  Are there different algorithms or
  119. different ways of walking data structures to reduce the amount of
  120. paging? 
  121.  
  122. Use the Sprite malloc (with Mem_Bin & callers)?
  123.  
  124.  
  125.     - other VM -
  126.  
  127. Make the Vm_Copy{In,Out} code avoid vm_{read,write} calls when
  128. possible (when dealing with server addresses)?  Note that
  129. copy-on-write can only be used when the destination is backed by the
  130. default pager (rather than an external pager).
  131.  
  132. Avoid using CopyIn/CopyOut by using a bounded string argument (e.g.,
  133. for file names & such)?
  134.  
  135. When copying in arguments and environment variables from user space,
  136. would probably be faster if you ensure that the server's buffer is
  137. page-aligned (assuming you're still using Vm_CopyIn).  In fact, it
  138. might be worthwhile revisiting the interface presented by
  139. Vm_Copy{In,Out} to see if you can change it into something that
  140. doesn't cause so much byte copying.
  141.  
  142. Keep counts for the number of 1-page, 2-page, 3-page, etc. page-ins
  143. and page-outs?
  144.  
  145. Reduce the number of copies by using memory_object_data_supply with
  146. deallocate?
  147.  
  148.  
  149.     - timer -
  150.  
  151. Are you getting burned by having elements in the timer queue processed
  152. too late?  (See notes for 12 November 1991).  Should you re-enable the
  153. Proc_SetPriority call in TimerThread()?
  154.  
  155. The current timer code tries to schedule wakeups to the nearest
  156. millisecond, since that's what Mach advertises.  First, does the
  157. implementation really meet the specs, or is the granularity for
  158. wakeups coarser than 1ms?  Second, would you be better off by reducing
  159. overhead by upping the Sprite granularity to 10ms or 20ms?
  160.  
  161. For systems that don't have a mapped timer, how expensive is
  162. Timer_GetTimeOfDay?  Should it always be called by TransferInProc?
  163. (If not, an alternative is to put something in the timer queue to run
  164. every N seconds and see whether there has been any console input in
  165. the previous interval.)
  166.  
  167.  
  168.     - file system -
  169.  
  170. Look at Fsrmt_Read and Fsrmt_Write.  Notice the user of an
  171. intermediary buffer between the user buffer and the RPC packet
  172. (costing an extra alloc and copy).  Can this be fixed?  For example,
  173. JO has suggested mapping one or two pages of each user process
  174. directly into the server address space, keeping the mappings around
  175. from call to call until a different address is needed.  Does this
  176. alloc/copy problem show up in other stream types?
  177.  
  178.  
  179.     - signals -
  180.  
  181. Are there any applications where signal-handling performance is
  182. critical (e.g., for SIGIO)?
  183.  
  184.  
  185.     - Sprite "system" calls -
  186.  
  187. How much do you lose from the extra context switch (between the thread
  188. that reads messages and the thread that processes the request)?
  189.  
  190. Is there a performance loss from creating/destroying the thread that
  191. processes the request (rather than keeping a pool of them)?
  192.  
  193. Do you have too many paranoia checks?
  194.